package com.chilli.cosima.data.dao.impl;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

import com.chilli.cosima.data.BaseHibernateDAO;
import com.chilli.cosima.data.bean.Provider;
import com.chilli.cosima.data.dao.ProviderDAO;

public class ProviderDAOImpl extends BaseHibernateDAO implements ProviderDAO
{

	public Integer createProvider(Provider provider)
	{
		return (Integer) createObject(provider);
	}

	public void deleteProvider(Integer[] id)
	{
		for (Integer tempId : id)
		{
			deleteObject(getObjectById(Provider.class, tempId));
		}
	}

	public Provider findProviderById(Integer id)
	{
		return (Provider) getObjectById(Provider.class, id);
	}

	@SuppressWarnings("unchecked")
	public Map findProviderByPage(int current, int pageSize)
	{
		Map map = new HashMap();
		List list = findObjectByHQL(" from Provider", new String[]
		{}, current, pageSize);

		int count = findObjectByHQL("from Provider").size();

		map.put("count", count);
		map.put("list", list);
		return map;
	}

	public void updateProvider(Provider provider)
	{
		updateObject(provider);
	}

}
